package summer.tree;

public class Solution513 {
    int deep = Integer.MIN_VALUE;
    int res;

    public int findBottomLeftValue(TreeNode root) {
        getValue(root, 0);
        return res;
    }

    public void getValue(TreeNode root, int height) {
        if (root == null) return;
        if (root.left == null && root.right == null) {
            if (height > deep) {
                deep = height;
                res = root.val;
            }
        }
        getValue(root.left, height + 1);
        getValue(root.right, height + 1);
    }
}
